package com.projet.erp;

import com.core.common.FnKit;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class CheckMain {
    public static void main(String[] args) {
        Connection connectionErp = null;
        Connection connectionMes = null;
        Statement statementErp = null;
        Statement statementMes = null;
        ResultSet rsErp;
        ResultSet rsMes;
        try {
            connectionErp = ERP.getConn();
            connectionMes = MES.getConn();
            statementErp = connectionErp.createStatement();
            statementMes = connectionErp.createStatement();
            String sql = "select material_no   from kd_material_info ";

            rsErp = statementErp.executeQuery(sql);
            List<String> noList = new ArrayList<>();
            while (rsErp.next()) {
                noList.add(rsErp.getString("material_no"));
            }
            String s;
            List<String> notExists = new ArrayList<>();
            for (String no : noList) {
                s = "select id  from  md_material where material_no = '" + no + "' ";
                rsMes = statementMes.executeQuery(s);
                if (!rsErp.next()) {
                    notExists.add(no);
                }
                try {
                    rsMes.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

            }
            System.out.println("涉及到的号：\r\n" + FnKit.join(notExists));
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            CloseUtil.deal(connectionErp, connectionMes, statementErp, statementMes);
        }

    }


}
